home *** CD-ROM | disk | FTP | other *** search
- /*
- ChkScenes.rexx
-
- Copyright (C) 1994 Earl C. Terwilliger
- Phone (606)-723-5718
-
- Internet: AISTERWI@ACS.EKU.EDU
- Conmpuserve: 70575,1330
-
- Non-Commercial USE granted to ALL !!!
-
- One of the problems with giving a LW scene
- to someone else is that you have to give
- the other files that are referenced in
- the scene file too. The reference in the
- LW scene file is to the complete file name
- including drive and path. You can easily
- forget to include a file when copying your
- scene and files to diskette.
-
- ChkScenes.rexx checks Lightwave Scene files to make
- sure that the file names referenced in the scene
- do indeed exist. Any referenced object file is
- also checked to verify the existance of maps
- (texture, reflection) that the object is using.
-
- If a file is not found that is referenced, an error
- message and the file name is displayed along with
- the LW scene command which references the file name.
- Some files may not be found due to no reference to
- their drive:directory. LW layouts default is then to
- look for those files in its default location which
- is OK if they are found there. This script only
- checks the directory structure if the drive:directory
- is specified. (It also checks the path from the
- drive:directory of the specified scene file for
- any files which are referenced by it that do not
- have a drive:directory prefix.)
-
- Syntax: rx ChkScenes drive:[directory]
-
- The only required parameter is the drive.
- The directory is optional. (Actually if you have
- only one directory to check, it is faster to
- specify it, since this AREXX script will
- recursively check thru each sub-directory
- looking for scene files which may take a while.
-
- Note: The ChkScenes.rexx script checks an
- entire drive:[directory] for all LW scenes files
- it finds whereas the ChkScene.rexx script only
- checks a single LW scene file.
-
- */
-
- /* TRACE(RESULTS) */
- OPTIONS RESULTS
- parse arg dir
-
- if arg() = 0 then call syntax()
- if ~exists(dir) then call syntax()
-
- if ~show('L',"rexxsupport.library") then do
- if addlib('rexxsupport.library',0,-30,0) then
- say "Added rexxsupport.library."
- else do
- say "Error: addlib() of rexxsupport.library failed."
- exit 10
- end
- end
-
- call main(dir)
- say
- say '<- Check Scenes Completed ->'
- exit 0
-
- main: procedure
- parse arg dir
- OPTIONS RESULTS
- filelist = showdir(dir,'ALL')
- if right(dir,1) ~= ":" then dir = dir||"/"
- i = 1
- do while word(filelist,i) ~= ''
- filename = dir||word(filelist,i)
- type = statef(filename)
- if (word(type,1) = 'DIR') then do
- call main(filename)
- end
- else do
- if (word(type,1) = 'FILE') then do
- call check(filename)
- end
- end
- i = i + 1
- end
- return 0
-
- check: procedure expose dir
- parse arg file
- OPTIONS RESULTS
- open('infile',file,'R')
- instring=readln('infile')
- if (pos('LWSC',instring) ~= 1) then do
- close('infile')
- return 1
- end
-
- say
- say '[Scene File Name]' file
-
- if (index(file,':') ~= 0) then do
- temp = translate(file," ","/:"," ")
- tempwords = words(temp)
- name = word(temp,tempwords)
- source = left(file,length(file)-length(name))
- end
- else source = dir
- if (right(source,1) ~= ':') then do
- if (right(source,1) ~= '/') then source = source||'/'
- end
-
- do while eof('infile')=0
- instring = readln('infile')
- lwcmd = word(instring,1)
- c = index(lwcmd,'Load')
- if (index(instring,':') ~= 0) then do
- if (index(instring,'/') ~= 0) then c = c + 1
- end
- if (c > 0) then do
- filename = word(instring,2)
- if (index(instring,':') = 0) then do
- if (left(filename,1) ~= '/') then filename = source||filename
- else filename = source||strip(filename,'L','/')
- end
- temp = upper(translate(filename," ","/:"," "))
- c = showlist('A',word(temp,1))
- c = c + showlist('H',word(temp,1))
- if (c = 0) then do
- say instring
- call errmsg('Volume Not Mounted - ERROR')
- end
- else if (~exists(filename)) then do
- temp = translate(filename," ","/:"," ")
- tempwords = words(temp)
- name = word(temp,tempwords)
- objname = source||'objects/'||name
- if (exists(objname)) then do
- say filename 'exists as' objname
- filename = objname
- if (index(lwcmd,"LoadObject") ~= 0) then call readlwob()
- end
- else do
- say instring
- call errmsg('File not Found - ERROR')
- end
- end
- else do
- say instring ' [OK]'
- if (index(lwcmd,"LoadObject") ~= 0) then call readlwob()
- end
- end
- end
- close('infile')
- say
- say '<- Check Scene completed for file ->' file
- return 0
-
- syntax:
- say
- say 'Syntax: rx ChkScenes drive:[directory]'
- say
- exit 10
-
- readlwob: PROCEDURE EXPOSE source filename
- OPTIONS RESULTS
-
- open('lwobfile',filename,'R')
- objstring = readch('lwobfile',12)
-
- type = substr(objstring,9,4)
-
- if (type ~= "LWOB") then do
- close('lwobfile')
- say filename
- call errmsg('This is not a LW Object file! - ERROR')
- return 10
- end
-
- form = substr(objstring,1,4)
- length = c2d(substr(objstring,5,4),4)
- length = length + 8
-
- say 'Reading from' filename
- /* say 'Object file length is' length 'bytes' */
-
- open('lwobout',destname,'W')
-
- do while eof('lwobfile')=0
- objstring=readch('lwobfile',8)
- if (eof('lwobfile') = 1) then break
- chunk = substr(objstring,1,4)
- length = c2d(substr(objstring,5,4),4)
- /* say 'Chunk Type is' chunk 'with a length of' length 'bytes' */
- if (chunk ~= "SURF") then seek('lwobfile',length,'C')
- else do
- objstring = readch('lwobfile',length)
- surfacepos = pos('00'x,objstring,1)
- surface = substr(objstring,1,(surfacepos-1))
- surfacepos = surfacepos + (surfacepos // 2) + 1
- say 'Surface Name:' surface
- do while (surfacepos < length)
- subchunk = substr(objstring,surfacepos,4)
- /* say 'Subchunk ' subchunk */
- surfacepos = surfacepos + 4
- len = c2d(substr(objstring,surfacepos,2),4)
- surfacepos = surfacepos + 2
- image = ""
- if (subchunk = "TIMG") then do
- image = strip(substr(objstring,surfacepos,len),'T','00'x)
- say 'Texture Image ->' image
- end
- if (subchunk = 'RIMG') then do
- image = strip(substr(objstring,surfacepos,len),'T','00'x)
- say 'Reflection Image ->' image
- end
- if (image = "(none)") then image = ""
- if (image ~= "") then do
- if (index(image,':') = 0) then do
- if (left(image,1) ~= '/') then fullimage = source||image
- else fullimage = source||strip(image,'L','/')
- end
- else fullimage = image
- temp = translate(fullimage," ","/:"," ")
- tempwords = words(temp)
- name = word(temp,tempwords)
- directory = left(fullimage,length(fullimage)-length(name))
- if (~exists(directory)) then do
- if (exists(source||"images")) then fullimage = source||'images/'||name
- end
- if (index(image,"(sequence)",1) = 0) then do
- if (~exists(fullimage)) then do
- say fullimage
- call errmsg('File Not Found - ERROR')
- end
- end
- end
- surfacepos = surfacepos + len
- end
- end
- end
-
- close('lwobfile')
- return 0
-
- errmsg: procedure
- parse arg msg
- len = length(msg) - 1
- errmsg = '|___________________________________________________________________________'
- errmsg = overlay(msg,errmsg,length(errmsg)-len,len+1)
- say errmsg
- return 0
-